//=========================================================================
// Copyright (C) 2021 The C++ Component Model(COMO) Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//=========================================================================

#ifndef __DPRAM_UTILS_H__
#define __DPRAM_UTILS_H__

#include <comolock.h>

using namespace como;

/**
 * initialize the DPRAM management information, success return 0, else error
 * code
 */
int dpramInit();

/**
 * mount a DPRAM Partition, fail return nullptr
 */
void *dpramMountPartition(int idPartition);

/**
 * get Spinlock in MainPartition
 */
Spinlock *dpramGetSpinlock(int idSpinlock);

/**
 * set value for a key
 */
int dpramSetkey(void *md, int keyidx, void *buffer, int valueCapacity);

/**
 * free value of the key "keyidx"
 */
int dpramFreeKey(void *md, int keyidx);

/**
 * get value by keyidx into value buffer, if valueCapacity < 0, don't fill
 * buffer, return the pointer directly
 */
void *dpramGetValue(void *md, int keyidx, void *buffer, int valueCapacity);

#endif  // __DPRAM_UTILS_H__
